#!/bin/bash

# Backup old configuration to /etc/self-service-password
for file in $( find /usr/share/self-service-password/conf -name "*.php" -type f ! -name 'config.inc.php' -printf "%f\n" 2>/dev/null );
do
    # move conf file to /etc/self-service-password/*.save
    mkdir -p /etc/self-service-password
    mv /usr/share/self-service-password/conf/${file} /etc/self-service-password/${file}.save
done

if [[ -f "/usr/share/self-service-password/conf/config.inc.php"  ]]; then
    # move specific file config.inc.php to /etc/self-service-password/*.bak
    mkdir -p /etc/self-service-password
    mv /usr/share/self-service-password/conf/config.inc.php \
       /etc/self-service-password/config.inc.php.bak
fi
